package com.shanxi.cz.module.biz.dal.mysql.ammeterrecord;

import com.shanxi.cz.framework.common.pojo.PageResult;
import com.shanxi.cz.framework.mybatis.core.mapper.BaseMapperX;
import com.shanxi.cz.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.shanxi.cz.module.biz.controller.admin.ammeterrecord.vo.AmmeterRecordPageReqVO;
import com.shanxi.cz.module.biz.dal.dataobject.ammeterrecord.AmmeterRecordDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 电表数据记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface AmmeterRecordMapper extends BaseMapperX<AmmeterRecordDO> {

    default PageResult<AmmeterRecordDO> selectPage(AmmeterRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AmmeterRecordDO>()
                .eqIfPresent(AmmeterRecordDO::getAmmeterId, reqVO.getAmmeterId())
                .betweenIfPresent(AmmeterRecordDO::getRecordTime, reqVO.getRecordTime())
//                .betweenIfPresent(AmmeterRecordDO::getRecordDate, reqVO.getRecordDate())
                .eqIfPresent(AmmeterRecordDO::getHz, reqVO.getHz())
                .eqIfPresent(AmmeterRecordDO::getVoltageA, reqVO.getVoltageA())
                .eqIfPresent(AmmeterRecordDO::getVoltageB, reqVO.getVoltageB())
                .eqIfPresent(AmmeterRecordDO::getVoltageC, reqVO.getVoltageC())
                .eqIfPresent(AmmeterRecordDO::getElectricityA, reqVO.getElectricityA())
                .eqIfPresent(AmmeterRecordDO::getElectricityB, reqVO.getElectricityB())
                .eqIfPresent(AmmeterRecordDO::getElectricityC, reqVO.getElectricityC())
                .eqIfPresent(AmmeterRecordDO::getPower, reqVO.getPower())
                .eqIfPresent(AmmeterRecordDO::getEng, reqVO.getEng())
                .eqIfPresent(AmmeterRecordDO::getOperateType, reqVO.getOperateType())
                .betweenIfPresent(AmmeterRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AmmeterRecordDO::getId));
    }

    default List<AmmeterRecordDO> selectByParams(AmmeterRecordPageReqVO pageReqVO) {
        return selectList(new LambdaQueryWrapperX<AmmeterRecordDO>()
                .eqIfPresent(AmmeterRecordDO::getAmmeterId, pageReqVO.getAmmeterId())
                .eqIfPresent(AmmeterRecordDO::getRecordDate, pageReqVO.getRecordDate())
                .orderByDesc(AmmeterRecordDO::getCreateTime));
    }
}